package com.openiotalk.firereader.api;

import com.openiotalk.firereader.bean.FeedArticleData;
import com.openiotalk.firereader.bean.FeedArticleReq;
import com.openiotalk.firereader.bean.FeedData;
import com.openiotalk.firereader.bean.FeedCategory;
import com.openiotalk.firereader.bean.FeedRss;

import com.openiotalk.firereader.bean.FeedResponse;
import com.openiotalk.firereader.bean.LoginData;
import com.openiotalk.firereader.bean.SignUpReq;
import com.openiotalk.firereader.bean.SigninReq;
import com.openiotalk.firereader.model.UpdateInformation;


import java.util.List;

import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;

/**
 * des:ApiService
 * Created by xsf
 * on 2016.06.15:47
 */
public interface ReaderApiService {

    @FormUrlEncoded
    @POST("/api/auth/signin")
    Observable<FeedResponse<LoginData>> login(
            @Field("username")String username,
            @Field("password")String password);

    @FormUrlEncoded
    @POST("/api/auth/signinByQQ")
    Observable<FeedResponse<LoginData>> loginByQQ(
            @Body SigninReq jsonBody);

    @POST("/api/auth/signinByGithub")
    Observable<FeedResponse<LoginData>> loginByGithub(
            @Body SigninReq jsonBody);

    @FormUrlEncoded
    @POST("/api/auth/signup")
    Observable<FeedResponse<LoginData>> signup(
            @Field("username")String username,
            @Field("nickname")String nickname,
            @Field("password")String password,
            @Field("rePassword")String rePassword
            );

    @FormUrlEncoded
    @POST("/api/auth/signout")
    Observable<FeedResponse<Boolean>> logout(
            @Header("X-User-Token") String usertoken);

    //TODO
    //rss
    @GET("/api/category/feed")
    Observable<FeedResponse<List<FeedCategory>>> getRssCategories(
            @Header("Cache-Control") String cacheControl);

    @GET("/api/rss/category")
    Observable<FeedResponse<List<FeedRss>>> getRssList(
            @Query("category") String category,
            @Query("size") int size,
            @Query("page") int page);


    @POST("/api/rss/add")
    Observable<FeedResponse<Boolean>> addRss(
            @Header("X-User-Token") String usertoken,
            @Body FeedRss jsonBody);

    //TODO  feed/collect
    @POST("/api/article/add")
    Observable<FeedResponse<Boolean>> addArticle(
            @Header("X-User-Token") String usertoken,
            @Body FeedArticleReq jsonBody );

    @POST("/api/article/favorite/{articleId}")
    Observable<FeedResponse<Boolean>> favoriteArticle(
            @Header("X-User-Token") String usertoken,
            @Path("articleId") Long articleId);

    //my/hot/new/recommend
    @GET("/api/article/category/list")
    Observable<FeedResponse<List<FeedArticleData>>> getArticleListByCategory(
            @Query("category") String category,
            @Query("size") int size,
            @Query("page") int page);

    @GET("/api/article/user/list")
    Observable<FeedResponse<List<FeedArticleData>>> geArticleListByUser(
            @Query("user") String userName,
            @Query("size") int size,
            @Query("page") int page);

    @GET("/api/article/recommend")
    Observable<FeedResponse<List<FeedArticleData>>> getRecommendArticleList(
            );


    @POST("/api/checkAppUpdate")
    Observable<FeedResponse<UpdateInformation>> checkAppUpdate(
            );


}
